VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree Namespace / PdfPage Class / RemoveText Methods / RemoveText(RectangleF[]) Method
Syntax Remarks Example Requirements SeeAlso
In This Topic
    RemoveText(RectangleF[]) Method (PdfPage)
    In This Topic
    Removes text that contains in specified rectangles of PDF page.
    Syntax
    'Declaration
    
    Public Overloads Sub RemoveText( _
    ByVal ParamArray rects
    The array of rectangles, in PDF page space (user units).
    () As System.Drawing.RectangleF _
    )
    public void RemoveText(
    params System.Drawing.RectangleF[] rects
    )
    public: void RemoveText(
    params System.Drawing.RectangleF*[]* rects
    )
    public:
    void RemoveText(
    ... array<System.Drawing.RectangleF^>^ rects
    )

    Parameters

    rects
    The array of rectangles, in PDF page space (user units).
    Remarks

    Important! - PDF document must be packed (Pack) after content removal otherwise the removed content can be restored.

    Example

    Here is an example that shows how to remove text in the specified rectangle of PDF page:

    
    Public Shared Sub TestRemoveTextOnAllPages(inputPdfFilename As String, outputPdfFilename As String)
        ' open document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(inputPdfFilename)
            ' for all pages
            For Each page As Vintasoft.Imaging.Pdf.Tree.PdfPage In document.Pages
                Dim rect As System.Drawing.RectangleF = page.MediaBox
                rect.Inflate(New System.Drawing.SizeF(-rect.Width / 4, -rect.Height / 4))
                ' remove text that containts with specified rectangle on PDF page
                page.RemoveText(rect)
            Next
            ' pack document
            If inputPdfFilename = outputPdfFilename Then
                document.Pack()
            Else
                document.Pack(outputPdfFilename)
            End If
        End Using
    End Sub
    
    
    
    public static void TestRemoveTextOnAllPages(string inputPdfFilename, string outputPdfFilename)
    {
        // open document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(inputPdfFilename))
        {
            // for all pages
            foreach (Vintasoft.Imaging.Pdf.Tree.PdfPage page in document.Pages)
            {
                System.Drawing.RectangleF rect = page.MediaBox;
                rect.Inflate(new System.Drawing.SizeF(-rect.Width / 4, -rect.Height / 4));
                // remove text that containts with specified rectangle on PDF page
                page.RemoveText(rect);
            }
            // pack document
            if (inputPdfFilename == outputPdfFilename)
                document.Pack();
            else
                document.Pack(outputPdfFilename);
        }
    }
    
    

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also